package com.zkny.zknyerp.controller;

import com.zkny.zknyerp.model.Device;
import com.zkny.zknyerp.service.DeviceService;
import com.zkny.zknyerp.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 用户对外接口
 */
@RestController
@RequestMapping("/api/device")
@CrossOrigin
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    @PostMapping("/addDevice")
    public Result addDevice(@RequestBody Device device){
        return deviceService.addDevice(device);
    }

    @GetMapping("/getDevice")
    public Result getDevice(Integer page,Integer limit){
        return deviceService.getDevice(page, limit);
    }

    @DeleteMapping("deleteDevice")
    public Result deleteDevice(@RequestBody Device device){
        return deviceService.deleteDevice(device);
    }

    @PostMapping("/updateDevice")
    public Result updateModel(@RequestBody Device device){
        return deviceService.updateDevice(device);
    }

    @GetMapping("/getDev")
    public Result getDev(Integer id){
        return deviceService.getDev(id);
    }

    @GetMapping("/getAppDevice")
    public Result getAppDevice(String imei){
        return deviceService.getAppDevice(imei);
    }

    @GetMapping("/getDevkey")
    public Result getDevkey(String imei,String devkey){
        return deviceService.getDevkey(imei,devkey);
    }

    @GetMapping("/getImei")
    public Result getImei(String imei,Integer page,Integer limit){
        return deviceService.getImei(imei,page,limit);
    }

}
